package org.example.service;

import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class LotteryService {
    public List<String> d(String n){
        int i = 1;
        try {
            i = Integer.parseInt(n);
        } catch (NumberFormatException e) {
        } finally {
            ArrayList<String> list = new ArrayList<>();
            for (int i1 = 0; i1 < i; i1++) {
                list.add(randomab(35,5).toString()+" "+randomab(12,2).toString());
            }
            return list;
        }
    }

    public List<String> s(String n){
        int i = 1;
        try {
            i = Integer.parseInt(n);
        } catch (NumberFormatException e) {
        } finally {
            ArrayList<String> list = new ArrayList<>();
            for (int i1 = 0; i1 < i; i1++) {
                list.add(randomab(33,6).toString()+" "+randomab(16,1).toString());
            }
            return list;
        }
    }

    List<Integer> randomab(int a,int b){
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < b; i++) {
            int i1 = (int)(Math.random()*a)+1;
            if(!list.contains(i1)){
                list.add(i1);
            }else {
                i--;
            }
        }
        for (int i = 0; i < list.size(); i++) {
            for (int j = i+1; j < list.size(); j++) {
                if(list.get(i)>list.get(j)){
                    int temp = list.get(i);
                    list.set(i,list.get(j));
                    list.set(j,temp);
                }
            }
        }
        return list;
    }
}
